/*
 * Copyright (C) 2009 Otávio Scherer Garcia
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.technorati4j.entity;

import java.util.Date;

import org.jdom.Element;

import com.googlecode.technorati4j.util.Constants;
import com.googlecode.technorati4j.util.StringUtils;

/**
 * XXXXXXXXXXXXXXXXXXXXXXXXX.
 * 
 * @author Otávio Scherer Garcia
 * @version $Revision$
 * 
 */
public final class TagResponseItem {

    /** The entry title. */
    private String title;

    /** Entry blurb with term highlighting. */
    private String excerpt;

    /** Date entry created. */
    private Date created;

    /** Date post last updated. */
    private Date postUpdate;

    /** Blog entry URL. */
    private String permalink;

    /**
     * The weblog.
     */
    private Weblog weblog;

    public TagResponseItem(Element element) {
        title = element.getChildText("title");
        excerpt = element.getChildText("excerpt");
        created = StringUtils.toDate(element.getChildText("created"), Constants.DATE_FULL);
        postUpdate = StringUtils.toDate(element.getChildText("postupdate"), Constants.DATE_FULL);
        permalink = element.getChildText("permalink");
        weblog = new Weblog(element.getChild("weblog"));
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getExcerpt() {
        return excerpt;
    }

    public void setExcerpt(String excerpt) {
        this.excerpt = excerpt;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getPostUpdate() {
        return postUpdate;
    }

    public void setPostUpdate(Date postUpdate) {
        this.postUpdate = postUpdate;
    }

    public String getPermalink() {
        return permalink;
    }

    public void setPermalink(String permalink) {
        this.permalink = permalink;
    }

    public Weblog getWeblog() {
        return weblog;
    }

    public void setWeblog(Weblog weblog) {
        this.weblog = weblog;
    }

    @Override
    public String toString() {
        final StringBuilder str = new StringBuilder();
        str.append("title=");
        str.append(title);
        str.append("&excerpt=");
        str.append(excerpt);
        str.append("&created=");
        str.append(created);
        str.append("&postUpdate=");
        str.append(postUpdate);
        str.append("&permalink=");
        str.append(permalink);
        str.append("&weblog=");
        str.append(weblog);

        return str.toString();
    }
}
